package com.ruoyi.web.controller.diagmanage;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.BeanMapUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.diagmanage.domain.Intelligent;
import com.ruoyi.diagmanage.service.IntelligentService;
import com.ruoyi.generic.domain.*;
import com.ruoyi.generic.service.IGenericService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

import static com.ruoyi.common.core.domain.AjaxResult.success;

/**
 * 智能诊断模块
 */
@RestController
@RequestMapping("/intelligentcontroller")
public class intelligentController {

    @Autowired
    IntelligentService intelligentService;

    /**
     * 查询智能诊断数据
     * @return
     */
    @PostMapping("/queryIntelligent")
    public AjaxResult queryIntelligent(@RequestBody Intelligent intelligent, HttpServletResponse response)
    {

        List<Intelligent> intelligents = intelligentService.queryIntelligentList(intelligent);
        return success(intelligents);
    }

    /**
     *导出智能诊断数据
     * @return
     */
    @PostMapping("/retIntelligent")
    public void retIntelligent(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        Intelligent intelligent = BeanMapUtils.mapToBean(params,Intelligent.class);
        List<Intelligent> intelligents = intelligentService.queryIntelligentList(intelligent);
        ExcelUtil<Intelligent> util = new ExcelUtil<Intelligent>(Intelligent.class);
        util.exportExcel(response, intelligents, "数据分析");

    }


}
